import * as THREE from "three";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";

// 平行光源
// import { mesh, light } from "./1-DirectionalLight.js";
// 点光源
// import { mesh, light } from "./2-PointLight.js";
// 环境光
// import { mesh, light } from "./3-AmbientLight.js";
// 聚光灯
// import { mesh, light } from "./4-SpotLight.js";
// 半球光
// import { mesh, light } from "./5-HemisphereLight.js";
// 平面光
// import { mesh, light } from "./6-RectAreaLight.js";
// 各类helper
import { gridHelper,cameraHelper,arrowHelper,polarGridHelper } from "./7-Helper.js"


const scene = new THREE.Scene();
// scene.add(mesh, light);

//GridHelper 坐标格辅助对象
scene.add(gridHelper);
// CameraHelper 相机辅助对象
scene.add(cameraHelper);
// ArrowHelper 箭头辅助对象
scene.add( arrowHelper );
// PolarGridHelper 极坐标格辅助对象
scene.add(polarGridHelper);


// 创建相机
const camera = new THREE.PerspectiveCamera(
	60,
	window.innerWidth / window.innerHeight,
	0.1,
	10000 // 相机的范围
);
camera.position.set(200, 800, 800);
camera.lookAt(0, 0, 0);

// 创建渲染器
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// 渲染
function render() {
	requestAnimationFrame(render);
	renderer.render(scene, camera);
}
render();

//添加坐标轴辅助器
const axesHelper = new THREE.AxesHelper(200);
scene.add(axesHelper);

//轨道控制器
const controls = new OrbitControls(camera, renderer.domElement);
controls.addEventListener("change", function () {
	renderer.render(scene, camera);
});



